<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SHOP 管理中心 - 添加分类 </title>
<base href="__STATIC__/Admin/">
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h1>
<span class="action-span"><a href="{:url('Admin/Category/cate_list')}">商品分类</a></span>
<span class="action-span1"><a href="index.php?act=main">SHOP 管理中心</a> </span><span id="search_id" class="action-span1"> - 添加分类 </span>
<div style="clear:both"></div>
</h1>
<!-- start add new category form -->
<div class="main-div">
  <form action="{:url('Admin/Category/cate_add')}" method="post" id="theForm" enctype="multipart/form-data" onsubmit="return validate()">
	 <table width="100%" id="general-table">
		<tbody>
			<tr>
				<td class="label">分类名称:</td>
				<td><input type="text" name="cat_name" maxlength="20" value="" size="27"> <font color="red">*</font></td>
			</tr>
			<tr>
				<td class="label">上级分类:</td>
				<td>
					<input type="hidden" name="path" value="" id="path" />
					<select name="parent_id" id="select">
						<option value="0">顶级分类</option>
						{foreach $cate as $v}
							<option value="{$v.cat_id}" path="{$v.path}"><?php echo str_repeat("&nbsp;&nbsp;&nbsp;├",substr_count($v['new'],"-")-1) ?>{$v.cat_name}</option> 
						{/foreach} 
						       
					</select>
				</td>
			</tr>
			
			<tr>
				<td class="label">是否显示:</td>
				<td><input type="radio" name="is_show" value="1" checked="true"> 是<input type="radio" name="is_show" value="0"> 否  </td>
			</tr>
			<tr>
				<td class="label">是否显示在导航栏:</td>
				<td><input type="radio" name="is_nav" value="1"> 是  <input type="radio" name="is_nav" value="0" checked="true"> 否    </td>
			</tr>
      <tr>
        <td class="label">分类描述:</td>
        <td>
          <textarea name="cat_desc" rows="6" cols="48"></textarea>
        </td>
      </tr>
      </tbody></table>
      <div class="button-div">
        <input type="submit" value=" 确定 ">
        <input type="reset" value=" 重置 ">
      </div>
    <input type="hidden" name="act" value="insert">
    <input type="hidden" name="old_cat_name" value="">
  </form>
</div>
</div>

</body>
<script src="jquery.js"></script>
<script>
	$("#theForm").submit(function(event){
		//event.preventDefault();
		//获取当前添加分类的父级主键id 作为新添加类的parent_id
		var parent_id=$("#select :selected").val();
		var path=$("#select :selected").attr("path");
		//判断被选中的是否为顶级分类   如果是,其path为0  否则为path+"-"+parent_id
		if(parent_id==0){
			$("#path").val(0);
		}else{
			$("#path").val(path+"-"+parent_id);
		}

	})
</script>
</html>